import pandas as pd
import numpy as np

# plotting
#import seaborn as sn
import matplotlib.pyplot as plt


from matplotlib import pyplot

#读入数据
print('##########data reading########')
train = pd.read_csv("FE_GBDT.csv")
print('##########################')
print('Train shape',train.shape)
print('####positive and negetibe samples',train['click'].value_counts())

#Cat_features_MEncoder = ['site_id','site_domain','app_id','app_domain','device_id','device_ip','device_model','C14','C17','C20']
#抽取要训练特征
y_train = train['click']
X_train = train.drop(['click'], axis=1)
print('############################')
print('X_train shape',X_train.shape)

#用于后续特征重要性显示
feat_names = X_train.columns


#LR 默认
from sklearn.linear_model import LogisticRegression
lr= LogisticRegression()
# 交叉验证用于评估模型性能和进行参数调优（模型选择）
#分类任务中交叉验证缺省是采用StratifiedKFold
from sklearn.model_selection import cross_val_score

print('##################Training begin######################')
loss = cross_val_score(lr, X_train, y_train, cv=5, scoring='neg_log_loss')
print('LR logloss of each fold is: ',-loss)
print('LR cv logloss is:', -loss.mean())



